/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.niclun.projectwebshop.nbp;

import edu.chl.niclun.projectwebshop.nbp.Entities.Movie;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *BackingBean for the ViewCart.xhtml
 * @author niclas
 */
@ManagedBean(name="ViewCartBean")
@RequestScoped
public class ViewCartBackingBean {
    //the cart
    private Map<Movie, Integer> cart;
    private int count;
    //total cost
    private int totalCost;
    //total cost with shipping
    private int totCostIncShipping;
    //shipping cost
    private int shippingCost;
    private List<Movie> movieList;

    /** Creates a new instance of ViewCartSupportBean */
    public ViewCartBackingBean() {
        cart = new TreeMap<Movie, Integer>();
    }
    
    public Map<Movie, Integer> getCart() {
        return this.cart;
    }
    
    public void setCart(Map<Movie, Integer> cart) {
        this.cart = cart;
    }
    
    public int getCount() {
        return count;
    }
    
    public void setCount(int count) {
        this.count = count;
    }
    
    public int getCount(Movie m) {
        return cart.get(m);
    }
    
    public int getTotalCost(Movie movie) {
        return movie.getPrice() * getCount(movie);   
    }
    
    public int getTotalCost() {
        return totalCost;
    }
    
    public int getShippingCost() {
        return shippingCost;
    }
    
    public void setShippingCost(int shippingCost) {
        this.shippingCost = shippingCost;
    }
    
    public void setTotalCost(int totalCost) {
        this.totalCost = totalCost;
    }
    
    public int getTotCostIncShipping() {
        return totCostIncShipping;
    }
    
    public void setTotCostIncShipping(int totCostIncShipping) {
        this.totCostIncShipping = totCostIncShipping;
    }
    
    public List<Movie> getMovieList() {
        return movieList;
    }
    
    public void setMovieList(List<Movie> movieList) {
        this.movieList = movieList;
    }
}